{extend name='public/layout' /}
{block name='content'}
<div class="main">
    <div class="position">
        <p>
            您当前的位置：<a href="{:url('Index/index')}">{$site.title}</a> > <a href="{:url('Question/index')}">问答</a>
        </p>
    </div>
    <div class="overflow_h m_t_15">
        <div class="body_left">
            <form action="{:url('Ajax/question')}" id="form"  method="post">
                <div class="ask_list_r01">
                    <p><input type="text" style="width:80%;" class="inp07" name="title" id="title" placeholder="请输入标题" /></p>
                    <p><textarea name="content" class="inp08" style="width:80%;" id="content" placeholder="请在这输入问题详细内容描述"></textarea></p>
                    <p class="overflow_h"><span class="adl_list_sp1">
  <select class="select03" name="cate_id" id="cate_id">
      {volist name='cate["tree"]' id='val'}
      <option value="{$val.id}" {present name="val._child"}disabled{/present}>{$val.name}</option>
      {present name='val._child'}
      {volist name='val._child' id='vo'}
      <option value="{$vo.id}">--{$vo.name}</option>
      {/volist}
      {/present}
      {/volist}
  </select>
</span><span class="adl_list_sp2"><a  href="javascript:;" id="askBut" class="but35">提交问题</a></span></p>
                </div>
            </form>
        </div>
        <div class="body_right">
            <div class="m_t_15">
                <div class="ask_fenlei">
                    <h1 class="ask_fenl">问答分类</h1>
                    {volist name="cate['tree']" id='val'}
                    <h2>{$val.name}</h2>
                    <ul class="overflow_h">
                        {present name='val._child' id='vo'}
                        {volist name='val._child' id='vo'}
                        <li><a title="{$vo.name}" href="{:url('Question/index',['cate_id'=>$vo['id']])}">{$vo.name}</a></li>
                        {/volist}
                        {/present}
                    </ul>
                    {/volist}
                </div>
            </div>
        </div>
    </div>
</div>
<script src="__PUBLIC__/js/layer/layer.js"></script>
<script src="__PUBLIC__/js/plugins/jquery.ajax.form.js"></script>
<script>
    $(function(){
        $('#askBut').bind('click',function(){
            var title = $('#title').val();
            var content = $('#content').val();
            var cate_id = $('#cate_id').val();
            if(title.length==0){
                layer.msg('请填写标题',{icon:2});
                return false;
            }
            if(content.length==0){
                layer.msg('请填写内容',{icon:2});
                return false;
            }
            if(cate_id==0){
                layer.msg('请选择分类',{icon:2});
                return false;
            }
            $('#form').submit();
        });
        $('#form').ajaxForm({success:complate,dataType:'json'});
        function complate(result){
            if(result.status == 1){
                layer.msg(result.msg,{icon:1});
                setTimeout(function(){
                    window.location.href = location.href + '?t='+Math.random();
                },3000);
            } else {
                layer.msg(result.msg,{icon:2});
            }
        }
    });
</script>
{/block}